package com.rbs.controller;

import com.rbs.service.Impl.PhoneServiceImpl;
import com.rbs.service.PhoneService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns = "/multiDelete")
public class MultiDelete extends HttpServlet {
    private PhoneService phoneService = new PhoneServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1 收参 得到一个集合
            String[] ids = request.getParameterValues("ids");
        for (String strId : ids) {
            int id = Integer.parseInt(strId);
            phoneService.deletePhoneById(id);
        }
        response.sendRedirect(request.getContextPath()+"/FindAllPhoneController");

    }
}
